package com.relife.common.utils;

import com.relife.core.dao.Jdbc;
import com.relife.core.spring.SpringContextUtil;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;



@Repository
public class GuanfangSmsUtil {
	private static final Logger log = Logger.getLogger("GuanfangSmsUtil");
	private static Jdbc jdbc = (Jdbc) SpringContextUtil.getService("jdbc");

	/**
	 * 
	 * @author WU
	 * @date 2016年3月2日 下午1:52:08
	 * @param phone
	 * @param msg
	 */
	public static void sendMsg(String phone, String msg) {
		StringBuffer sql = new StringBuffer();
		sql.append("insert into sms_outbox(sismsid, extcode, destaddr, messagecontent,reqdeliveryreport,msgfmt,sendmethod,requesttime,applicationid)");
		sql.append("values (replace(uuid(),'-',''), '9',?,?, 1, 15, 0, current_timestamp, 'gfjz_db');");
		jdbc.execute(sql.toString(), phone, msg);
		log.info("号码：" + phone + " 内容：" + msg);
	}

	public static void main(String[] args) {
		GuanfangSmsUtil.sendMsg("15912587944", "您好，阳光悦城七坊街B区-M-2-1的2017年03月的水电费已抄录，供电局账单已到，请于收到此通知起7日之内完成核对缴费。逾期未交我公司将进行停止水电供给。谢谢合作。");
	}
}
